package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.ApplicablePlatformEnum;
import com.frogs.system.util.GoodsEvaluateEnum;
import com.frogs.system.util.OpenPlatformEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 商品评价请求参数类
 *
 * @author lijian
 * @version 2014年3月15日 - 上午9:58:28
 */
public class GoodsEvaluateMergeRequest extends Request {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1572324325335187429L;
	/**
	 * 账号ID
	 */
	private int userId;
	/**
	 * 原始商品ID
	 */
	private int originalGoodsId;
	/**
	 * 商品ID
	 */
	private int goodsId;
	
	/**
	 * 订单编号
	 */
	private String orderId;

	/**套餐id*/
	private Integer mealId;
	
	/**
	 * 商品评分
	 */
	private int score;
	
	/**
	 * 是否药师认证评价
	 */
	private int isPharmacistEvaluate;
	/**
	 * 评价内容
	 */
	private String content;
	/**
	 * 标签IDs
	 */
	private String tagIds;
	/**
	 * 标签
	 */
	private String tag;
	/**
	 * 购买时间
	 */
	private String buyTime;
	/**
	 * 适用范围
	 */
	private int applicablePlatformId;
	
	private int openPlatformId;
	
	/** */
	public GoodsEvaluateMergeRequest() {
		
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.originalGoodsId = requestInfo.getIntParameter(ApiUrlParamEnum.originalGoodsId.getParamName(), 0);
		this.goodsId = requestInfo.getIntParameter(ApiUrlParamEnum.goodsId.getParamName(), 0);

		this.mealId = requestInfo.getIntParameter(ApiUrlParamEnum.mealId.getParamName(), 0);
		this.isPharmacistEvaluate = requestInfo.getIntParameter(ApiUrlParamEnum.isPharmacistEvaluate.getParamName(), GoodsEvaluateEnum.IS_PHARMACIST_EVALUATE_NO.getId());
		this.content = StringUtil.fixHtml(requestInfo.getParameter(ApiUrlParamEnum.content.getParamName(), ""));;

		this.tagIds = requestInfo.getParameter(ApiUrlParamEnum.tagIds.getParamName(), "");
		this.tag = StringUtil.fixHtml(requestInfo.getParameter(ApiUrlParamEnum.tag.getParamName(), ""));
		this.buyTime = requestInfo.getParameter(ApiUrlParamEnum.buyTime.getParamName(), "");
		this.applicablePlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.applicablePlatformId.getParamName(), ApplicablePlatformEnum.WEB.getId());
		this.score = requestInfo.getIntParameter(ApiUrlParamEnum.score.getParamName(), 0);
		this.openPlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.openPlatformId.getParamName(), OpenPlatformEnum.WECHAT_HDC.getId());
		this.orderId = requestInfo.getParameter(ApiUrlParamEnum.orderId.getParamName(), "-");
		if ( userId < 1 ) {
			throw new RequestIllegalException("error userId: " + userId);
		}
		if ( originalGoodsId < 1 ) {
			throw new RequestIllegalException("error originalGoodsId: " + originalGoodsId);
		}
		if ( goodsId < 1 && mealId < 1) {
			throw new RequestIllegalException("error goodsId or mealId: " + goodsId + ","+mealId);
		}
		if ( StringUtil.isEmpty(content) ) {
			throw new RequestIllegalException("error content: " + content);
		}
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getOriginalGoodsId() {
		return originalGoodsId;
	}

	public void setOriginalGoodsId(int originalGoodsId) {
		this.originalGoodsId = originalGoodsId;
	}

	public int getGoodsId() {
		return goodsId;
	}

	public void setGoodsId(int goodsId) {
		this.goodsId = goodsId;
	}

	public Integer getMealId() {
		return mealId;
	}

	public void setMealId(Integer mealId) {
		this.mealId = mealId;
	}
	
	public int getIsPharmacistEvaluate() {
		return isPharmacistEvaluate;
	}

	public void setIsPharmacistEvaluate(int isPharmacistEvaluate) {
		this.isPharmacistEvaluate = isPharmacistEvaluate;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getTagIds() {
		return tagIds;
	}

	public void setTagIds(String tagIds) {
		this.tagIds = tagIds;
	}

	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	public String getBuyTime() {
		return buyTime;
	}

	public void setBuyTime(String buyTime) {
		this.buyTime = buyTime;
	}

	public int getApplicablePlatformId() {
		return applicablePlatformId;
	}

	public void setApplicablePlatformId(int applicablePlatformId) {
		this.applicablePlatformId = applicablePlatformId;
	}

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public int getOpenPlatformId() {
		return openPlatformId;
	}

	public void setOpenPlatformId(int openPlatformId) {
		this.openPlatformId = openPlatformId;
	}
	
}
